class Blog < ApplicationRecord
  belongs_to :user
  has_many :comments, dependent: :destroy
  has_many :blog_follows, dependent: :destroy
  has_many :followed, -> {where(status: true)}, class_name: 'BlogFollow'
  has_many :unfollowed, -> {where(status: false)}, class_name: 'BlogFollow'
  default_scope -> { order(created_at: :desc) }

  validates :user_id, presence: true
  validates :content, presence: true, length: { maximum: 140 }

end
